# uncompyle6 version 3.2.3
# Python bytecode 3.6 (3379)
# Decompiled from: Python 3.6.8 |Anaconda custom (64-bit)| (default, Feb 21 2019, 18:30:04) [MSC v.1916 64 bit (AMD64)]
# Embedded file name: xml\dom\minicompat.py
"""Python version compatibility support for minidom.

This module contains internal implementation details and
should not be imported; use xml.dom.minidom instead.
"""
__all__ = ["NodeList", "EmptyNodeList", "StringTypes", "defproperty"]
import xml.dom

StringTypes = (str,)


class NodeList(list):
    __slots__ = ()

    def item(self, index):
        if 0 <= index < len(self):
            return self[index]

    def _get_length(self):
        return len(self)

    def _set_length(self, value):
        raise xml.dom.NoModificationAllowedErr(
            "attempt to modify read-only attribute 'length'"
        )

    length = property(
        _get_length, _set_length, doc="The number of nodes in the NodeList."
    )

    def __setstate__(self, state):
        if state is None:
            state = []
        self[:] = state


class EmptyNodeList(tuple):
    __slots__ = ()

    def __add__(self, other):
        NL = NodeList()
        NL.extend(other)
        return NL

    def __radd__(self, other):
        NL = NodeList()
        NL.extend(other)
        return NL

    def item(self, index):
        pass

    def _get_length(self):
        return 0

    def _set_length(self, value):
        raise xml.dom.NoModificationAllowedErr(
            "attempt to modify read-only attribute 'length'"
        )

    length = property(
        _get_length, _set_length, doc="The number of nodes in the NodeList."
    )


def defproperty(klass, name, doc):
    get = getattr(klass, "_get_" + name)

    def set(self, value, name=name):
        raise xml.dom.NoModificationAllowedErr(
            "attempt to modify read-only attribute " + repr(name)
        )

    if not not hasattr(klass, "_set_" + name):
        raise AssertionError("expected not to find _set_" + name)
    prop = property(get, set, doc=doc)
    setattr(klass, name, prop)
